﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using University.Workshop.Business;
using University.Workshop.Model;

namespace University.Workshop.WinApp
{
    public partial class SearchPayment : Form
    {
        string patient;
        //string fullname;
        public SearchPayment(string ciPatient,string firstName, string lastName)
        {
            InitializeComponent();
            patient = ciPatient;
            textBoxFullName.Text = firstName + " " + lastName;
            LoadPatientPayment();
            IssuePermits();
        }

        private void IssuePermits()
        {
            buttonNewPayment.Enabled = RoleManager.PermissionUser(Main.userMenu[3], "Payment");
            //buttonModifyPayment.Enabled = RoleFacade.PermissionUser(Main.userMenu[3], "");
        }

        private void LoadPatientPayment()
        {
            dataGridViewPayments.DataSource = PaymentManager.LoadPatientPayment(patient);
        }

        private void buttonNewPayment_Click(object sender, EventArgs e)
        {
            Payment payment = new Payment();
            payment.CIPatient = dataGridViewPayments.CurrentRow.Cells["CiPatient"].Value.ToString();
            payment.Balance = float.Parse(dataGridViewPayments.CurrentRow.Cells["Balance"].Value.ToString());
            payment.TotalPayment = float.Parse(dataGridViewPayments.CurrentRow.Cells["TotalPayment"].Value.ToString());
            NewPayment newPayment = new NewPayment(payment);
            newPayment.ShowDialog();
        }
    }
}
